package regex;

import java.util.regex.Pattern;

public final class Color {
	private final String name;

	public Color(String name) {
		this.name = name;
	}

	public String getName() {
		return name;
	}

	public String toString() {
		return this.name;
	}
	
	public static boolean isColor(String value) {
		Pattern p = Pattern.compile("^[a-zA-Z ]+$");
		return p.matcher(value).find();
	}
	
	public boolean equals(Object o) {
		if(!(o instanceof Color)) {
			return false;
		}
		Color c = (Color) o;
		return this.name.equalsIgnoreCase(c.getName());
	}
	
	public int hashCode() {
		int result = 17;
		result = 37 * result + this.name.hashCode();
		return result;
	}
	
}
